package de.sabram.upb.specs.eee_tools.wizards;

import java.net.URI;

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;

public class EmptyProjectWizard extends Wizard implements INewWizard {
	private WizardNewProjectCreationPage  _pageOne;
	
	public EmptyProjectWizard() {
		setWindowTitle("e³-Tools Project Wizard");
	}
	
	@Override
	public void addPages() {
	    super.addPages();

	    _pageOne = new WizardNewProjectCreationPage("e³-Tools Project Wizard");
	    _pageOne.setTitle("e³-Tools Project");
	    _pageOne.setDescription("Create an e³-Tools project from scratch.");

	    addPage(_pageOne);
	}
	
	@Override
	public void init(IWorkbench workbench, IStructuredSelection selection) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean performFinish() {
	    String name = _pageOne.getProjectName();
	    URI location = null;
	    if (!_pageOne.useDefaults()) {
	        location = _pageOne.getLocationURI();
	    } // else location == null

	    EEEProjectSupport.createProject(name, location);
	    return true;
	}
}
